#include<bits/stdc++.h>
using namespace std;
struct Node
{
    long long l,r;
};
Node ans[100005];
long long T,n,m,L,V,cnt=1;
long long d[100005],v[100005],a[100005];
long long p[100005]={0,1,3,4,6,8};
long long lar_sea(long double x)
{
    long long l=1,r=m,res=m+1;
    while(l<=r)
    {
        long long mid=(l+r)/2;
        if(p[mid]<x)
        {
            l=mid+1;

        }else{
            r=mid-1;res=mid;
        }
    }
    return res;
}
long long low_sea(long double x)
{
    long long l=1,r=m,res=1;
    while(l<=r)
    {
        long long mid=(l+r)/2;
        if(p[mid]<=x)
        {
            l=mid+1;res=mid;

        }else{
            r=mid-1;
        }
    }
    return res;
}
bool cmp(Node t1,Node t2)
{
    return t1.l<t2.l;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        cnt=1;
        cin>>n>>m>>L>>V;
        for(long long i=1;i<=n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
        }
        for(long long i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        for(long long i=1;i<=n;i++)
        {
            if(a[i]==0)
            {
                if(v[i]>V)
                {
                    long long t1=lar_sea(d[i]);
                    if(t1<=m)
                    {
                        ans[cnt++]=(Node){t1,m};
                    }
                }
            }else if(a[i]<0)
            {
                a[i]*=(-1);
                if(v[i]>V)
                {
                    long double x=(v[i]*v[i]-V*V)/2.0/a[i]-0.000001;
                    long long t1=lar_sea(d[i]);
                    long long t2=low_sea(d[i]+x);
                    if(t1<=t2)
                    {
                        ans[cnt++]=(Node){t1,min(t2,m)};
                    }
                }
            }else if(a[i]>0)
            {
                if(v[i]>V)
                {
                    long long t1=lar_sea(d[i]);
                    if(t1<=m)
                    {
                        ans[cnt++]=(Node){t1,m};
                    }
                }else{
                    long double x=(V*V-v[i]*v[i])/2.0/a[i]+0.000001;
                    long long t1=lar_sea(d[i]+x);
                    if(t1<=m)
                    {
                        ans[cnt++]=(Node){t1,m};
                    }
                }
            }
        }
        cnt--;
        cout<<cnt<<" ";
        sort(ans+1,ans+cnt+1,cmp);
        long long num=0,l,r;
        for(long long i=1;i<=cnt;i++)
        {
            if(num==0)
            {
                num=1;
                l=ans[i].l;
                r=ans[i].r;
            }else if(ans[i].l<=r)
            {
                l=ans[i].l;
                r=min(r,ans[i].r);
            }else{
                num++;
                l=ans[i].l;
                r=ans[i].r;
            }
        }
        cout<<m-num<<endl;
    }
    return 0;
}
